package com.example.javaproject;

import com.example.javaproject.okhttp.OKFileUtil;

import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.MessageFormat;

public class IOClass {
    public static void main(String[] args) {
        String s = "hello {0},i''m {1},{2}";

        MessageFormat temp = new MessageFormat(s);
        System.out.println(temp.format(new Object[]{"user", "developer", "goodBye"}));
        s="a={0}";
        temp.applyPattern(s);
        System.out.println(temp.format(new Object[]{2}));

        String[] paths = new String[]{"F:\\hot_styles_artist_en.txt", "F:\\hot_styles_artist_en.txt", "F:\\hot_styles_artist_en.txt"};
        System.out.println(System.currentTimeMillis());


        System.out.println(formatCommentNumber(888));
        System.out.println(formatCommentNumber(8188));

        OKFileUtil.download("https://pic1.zhimg.com/50/v2-ba780af3b170b112c48b721fb8826cf1_hd.webp", "e:/download", "three.webp");

/*        CommonAction<String, String> addHello = new CommonAction<String, String>( ) {

            @Override
            String invoke(String s) {
                return ("addHello+ ") + s;
            }
        };


        CommonAction<Integer, String> integerToString = new CommonAction<Integer, String>(addHello) {
            @Override
            String invoke(Integer integer) {
                return ("integerToString+ ")+integer;
            }
        };
        System.out.println(integerToString.doNext(5));*/


    }

    public static String formatCommentNumber(int number) {
        if (number < 1000) return number + "";
        float f = number / 1000f;
        DecimalFormat decimalFormat = new DecimalFormat("0.0");
        decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
        return decimalFormat.format(f) + "K";
    }
}
